﻿using System.IO;
using log4net.Config;
using NMock2;
using NUnit.Framework;

namespace SKBKontur.CassandraLogging.Tests
{
    [TestFixture]
    public abstract class TestBase
    {
        private static bool IsLog4NetConfigured;
        private Mockery mockery;

        protected T NewMock<T>()
        {
            return (T) mockery.NewMock(typeof (T));
        }

        [SetUp]
        public virtual void SetUp()
        {
            if (!IsLog4NetConfigured)
            {
                XmlConfigurator.Configure(new FileInfo("log4net.config"));
                IsLog4NetConfigured = true;
            }
            MockAppender.loggingEvents.Clear();
            mockery = new Mockery();
        }

        [TearDown]
        public virtual void TearDown()
        {
            mockery.Dispose();
        }
    }
}
